package lanou.autohome.forum;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;

/**
 * Created by dllo on 16/8/15.
 */
public class ForumAdapter extends FragmentPagerAdapter{

    ArrayList<Fragment>fragments;
    ArrayList<String> arrayList = new ArrayList<>();

    public void setFragments(ArrayList<Fragment> fragments) {
        this.fragments = fragments;
        arrayList.add("精选推荐");
        arrayList.add("热帖");
        arrayList.add("常用论坛");
        notifyDataSetChanged();
    }

    public ForumAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return arrayList.get(position);
    }



}
